<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home ref="home"></home>
    <button ref="btn">按钮</button>
    <h2 ref="title">标题</h2>
  </div>
  <script src="./vue.js"></script>
  <script>
    const Home = {
      template: `
        <div>
          <h2>home组件</h2>  
        </div>
      `,
      data(){
        return {
          msg:'home数据'
        }
      },
      methods: {
        fn(){
          console.log('home的方法');
        }
      }
    }
    
  
    const vm = new Vue({
      // vm功能将vue语法渲染到 视图
      el: '#app',
      components: {
        Home
      },
      mounted(){
        // console.log(document.querySelector('button'));
        console.log(this.$refs.home.msg);
        this.$refs.home.fn();
      }
    })
  </script>
</body>
</html>